import { View } from "../../../mvc/core/View";
import { LayerManager } from "../../manager/LayerManager";
import { Global } from "../../../../com/gengine/global/Global";
import { ObjCreate } from "../common/ObjCreate";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../extend/language/Language";
import { LoaderManager } from "../../../../com/gengine/resource/LoaderManager";
import { TowerInfoHideButton } from "../copy/magicTower/TowerInfoHideButton";
import { ImagesConst } from "../../resource/ImagesConst";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { ScrollBarDirection } from "../../../../fl/controls/ScrollBarDirection";
import { PeaceFieldDamageRender } from "./PeaceFieldDamageRender";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { SceneRange } from "../../scene/map/SceneRange";
import { TweenMax } from "../../../../com/greensock/TweenMax";
import { Quint } from "../../../../com/greensock/easing/Quint";
import { TaskCache } from "../../cache/TaskCache";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GButton } from "../../../../com/mui/controls/GButton";
type int = number;
//class PeaceFieldDamageRank
    
    export  class PeaceFieldDamageRank extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.uiLayer;
            this.x = Global.stage.stageWidth - PeaceFieldDamageRank.__width;
            this.y = PeaceFieldDamageRank.__y;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this.mouseEnabled = false;
            this._bodySp = new Object /* flash.display.Sprite */();
            this.addChild(this._bodySp);
            this._topSp = new Object /* flash.display.Sprite */();
            this._bodySp.addChild(this._topSp);
            this._moveBtn = ObjCreate.createGButton("", 0, 3, 24, 22, this._topSp, "MoveBtn");
            this._moveBtn.toolTipData = HTMLUtil.addColor(Language.getString(42007), "#FFFFFF");
            this._moveBtn.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, this.onMoveBtnHandler);
            this._moveBtn.addEventListener(flash.events.MouseEvent.MOUSE_UP, this.onMoveBtnHandler);
            this._btnDetails = ObjCreate.createGButton("", 22, 0, 188, 28, this._topSp, "TabButtonBig2");
            this._bmpDetails = new Object /* flash.display.Bitmap */();
            this._bmpDetails.y = 3;
            this._bmpDetails.x = 38;
            this._btnDetails.addChild(this._bmpDetails);
            LoaderManager.instance.load("PeaceFieldDamageText.png", this.onLoadComplete);
            this._zoomBtn = new TowerInfoHideButton(ImagesConst.PeaceFieldInfoButtonBg);
            this._zoomBtn.x = 222;
            this._zoomBtn.y = 13;
            this.addChild(this._zoomBtn);
            this._zoomBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onZoomBtnClick);
            this._spContent = new Object /* flash.display.Sprite */();
            this._spContent.mouseEnabled = false;
            this._spContent.y = 22;
            this._bodySp.addChild(this._spContent);
            var loc1=new Object /* flash.display.Bitmap */(new Object /* flash.display.BitmapData */(231, 210, true, 4278190080));
            loc1.alpha = 0.5;
            loc1.y = 1;
            this._spContent.addChild(loc1);
            var loc2=new GTextFormat(FontUtil.songtiName, 12, 15859633);
            loc2.align = flash.text.TextFormatAlign.CENTER;
            ObjCreate.createTextField(Language.getString(43302), 5, 5, 50, 20, this._spContent, loc2);
            ObjCreate.createTextField(Language.getString(43303), 55, 5, 90, 20, this._spContent, loc2);
            ObjCreate.createTextField(Language.getString(43304), 145, 5, 60, 20, this._spContent, loc2);
            this._damageList = new GTileList();
            this._damageList.setSize(220, 180);
            this._damageList.columnWidth = 200;
            this._damageList.rowHeight = 20;
            this._damageList.direction = ScrollBarDirection.VERTICAL;
            this._damageList.horizontalGap = 0;
            this._damageList.verticalGap = 0;
            this._damageList.styleName = "TileList";
            this._damageList.setStyle("skin", new Object /* flash.display.Bitmap */());
            this._damageList.setStyle("cellRenderer", PeaceFieldDamageRender);
            this._damageList.x = 5;
            this._damageList.y = 20;
            this._spContent.addChild(this._damageList);
            return;
        }

        public updateDamageList(arg1: Array<any>): void
        {
            this._damageList.dataProvider = new DataProvider(arg1);
            return;
        }

        /* internal  */onLoadComplete(arg1): void
        {
            this._bmpDetails.bitmapData = arg1.bitmapData as Object /* flash.display.BitmapData */;
            return;
        }

        /* internal  */onMoveBtnHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (arg1.type == flash.events.MouseEvent.MOUSE_DOWN) 
            {
                this.startDrag();
            }
            if (arg1.type == flash.events.MouseEvent.MOUSE_UP) 
            {
                this.stopDrag();
            }
            return;
        }

        /* internal  */onZoomBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._zoomBtn.show) 
            {
                this.hidePanel();
            }
            else 
            {
                this.showPanel();
            }
            return;
        }

        public hidePanel(): void
        {
            if (this._showTween && this._showTween.active) 
            {
                this._showTween.kill();
            }
            x = SceneRange.display.width - PeaceFieldDamageRank.__width + 26;
            y = PeaceFieldDamageRank.__y + 95;
            this._hideTween = TweenMax.to(this._bodySp, 0.2, {"x": PeaceFieldDamageRank.__width, "ease": Quint.easeOut, "onComplete": this.onHideEnd});
            this._zoomBtn.show = false;
            return;
        }

        /* internal  */onHideEnd(): void
        {
            if (this._bodySp.parent) 
            {
                removeChild(this._bodySp);
            }
            return;
        }

        public showPanel(): void
        {
            if (TaskCache.showTrack) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.TaskTrackShowOrHide, false));
            }
            if (this._hideTween && this._hideTween.active) 
            {
                this._hideTween.kill();
            }
            x = SceneRange.display.width - PeaceFieldDamageRank.__width;
            y = PeaceFieldDamageRank.__y;
            this._showTween = TweenMax.to(this._bodySp, 0.2, {"x": 0, "ease": Quint.easeIn});
            this._zoomBtn.show = true;
            if (!this._bodySp.parent) 
            {
                addChild(this._bodySp);
            }
            return;
        }

        public resetPosition(): void
        {
            this.x = Global.stage.stageWidth - PeaceFieldDamageRank.__width;
            this.y = PeaceFieldDamageRank.__y;
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            Dispatcher.addEventListener(EventName.TrackClick, this.onTaskTrackClick);
            return;
        }

        /* internal  */onTaskTrackClick(arg1: DataEvent): void
        {
            if (arg1.data && this._zoomBtn.show) 
            {
                this.hidePanel();
            }
            return;
        }

        public /* override */ dispose(arg1: Boolean=true): void
        {
            return;
        }

        /* internal */ static /* const */__width: number=260;

        /* internal */ static /* const */__y: number=193;

        /* internal */ /* var */_bodySp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_topSp: Object /* flash.display.Sprite */;

        /* internal */ /* var */_btn2: GButton;

        /* internal */ /* var */_moveBtn: GButton;

        /* internal */ /* var */_btnDetails: GButton;

        /* internal */ /* var */_bmpDetails: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_zoomBtn: TowerInfoHideButton;

        /* internal */ /* var */_spContent: Object /* flash.display.Sprite */;

        /* internal */ /* var */_damageList: GTileList;

        /* internal */ /* var */_hideTween: TweenMax;

        /* internal */ /* var */_showTween: TweenMax;

        public static /* var */Expand: string;

        public static /* var */Shrink: string;
    }

            PeaceFieldDamageRank.Expand = Language.getString(42014);
            PeaceFieldDamageRank.Shrink = Language.getString(42015);
        